package com.peng.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class TestController1 {

    //http://localhost:8080/t2?a=1&b=2
    @RequestMapping("t2")
    public String test( int a, int b, Model model){
        model.addAttribute("msg",a+b);
        return "hello";
    }

    @PostMapping("t3/{a}/{b}")
    public String test1(@PathVariable int a,@PathVariable int b,Model model){
        model.addAttribute("msg","结果为"+(a+b));
        return "hello";
    }
}
